package com.itheima.多态的使用;

public abstract class Cxy {
    public abstract void code();
}

class Coder1 extends Cxy {

    @Override
    public void code() {
        System.out.println("我来写持久层");
    }
}

class Coder2 extends Cxy {
    int age=26;
    String name="heima41期";
    char sex='男';

    @Override
    public void code() {
        System.out.println("我来写业务层");
    }
}

class Coder3 extends Cxy {

    @Override
    public void code() {
        System.out.println("我来写表现层");
    }
}

class Coder4 extends Cxy {

    @Override
    public void code() {
        System.out.println("我来写注释");
    }
}

class Coder5 extends Cxy {

    @Override
    public void code() {
        System.out.println("我来做测试");
    }
}

class Manager {
    public void test(Cxy coder) {
        coder.code();
    }
}

class T4 {
    public static void main(String[] args) {
        Manager m = new Manager();
        m.test(new Coder1());
        m.test(new Coder2());
        m.test(new Coder3());
        m.test(new Coder4());
        m.test(new Coder5());
        //Coder2 codeex=new Coder2();
        Cxy coder = new Coder2();
        coder.code();
        if(coder instanceof  Coder2){
            Coder2  coder2=(Coder2)coder;
            System.out.println(coder2.age);
        }else{
            System.out.println("不能使用多态的向下转型.......");
        }



        //System.out.println(codeex instanceof  Cxy);
        //System.out.println((coder instanceof  Coder2));
        //System.out.println((coder instanceof  Coder1));
        //System.out.println(coder2.age);

    }

}